feat: token revocation list#592
Merged
greatest0fallt1me merged 3 commits intoJun 29, 2026
Merged
Conversation
Issue CalloraOrg#509 - Per-developer API token revocation list with TTL - Created TokenRevocationService for in-memory revoked token tracking - Added sha256Hash field to ApiKeyRecord for efficient lookup - Integrated revocation check into gatewayRoutes for immediate invalidation - Added cleanup sweeper to remove expired entries automatically - Tests: 8 unit tests for TokenRevocationService, 2 integration tests
|
@ayomidearegbeshola29-dev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Per-Developer API Token Revocation List (#509)
Overview
Implements an in-memory revocation list with TTL support for immediate API token invalidation without database queries.
Problem
When an API key is revoked via DELETE
/api/keys/:id, the key is marked as revoked in the repository. However, subsequent gateway requests with that key would still fail the prefix/hash lookup before checking the revoked flag. For immediate invalidation, we need an in-memory check that can be performed before authentication.Solution
Created
TokenRevocationServicethat:Files Changed
New Files
src/services/tokenRevocation.ts- Core service implementationsrc/services/tokenRevocation.test.ts- Unit tests (8 tests)Modified Files
src/repositories/apiKeyRepository.tssha256Hashfield toApiKeyRecordinterfacegetSha256Hash(id)method to retrieve hash for revocation listsrc/routes/apiKeyRoutes.ts/api/keys/:idnow adds SHA-256 hash to in-memory revocation listsrc/routes/gatewayRoutes.tsAPI Changes
No breaking API changes. The revocation list is an internal optimization.
Flow
/api/keys/{keyId}apiKeyRepository.revoke()marks the key as revoked in storagegetSha256Hash()retrieves the SHA-256 hash of the revoked keyTokenRevocationService.revoke()adds hash to in-memory list with TTLisRevoked()before authenticationTest Coverage
TokenRevocationService(8 tests, 100% coverage)gatewayRoutes.test.tsfor revocation list checkapiKeyRoutes.test.tsfor revocation list update on DELETEConfiguration
Default TTL: 1 hour (3600000ms)
Default sweep interval: 1 minute (60000ms)
Can be configured via
getTokenRevocationService({ defaultTtlMs, sweepIntervalMs })closes #509